import 'package:flutter/material.dart';
import 'package:flutterdouban/model/homeModel/home_movelist_model.dart';
import 'package:flutterdouban/pages/home/home_movie_item.dart';
import 'package:flutterdouban/service/home_request.dart';

class JKHomeContent extends StatefulWidget {
  @override
  _JKHomeContentState createState() => _JKHomeContentState();
}

class _JKHomeContentState extends State<JKHomeContent> {
  /* 电影列表 */
  final List<MovieItem> moves = [];

  @override
  void initState() {
    // TODO: implement initState
    super.initState();

    print('-----------Start------------');
    final result = HomeRequest.requestMoveList(0).then((res) {
      print('请求的结果：$res');
      setState(() {
        moves.addAll(res);
      });
    });

    print('-----------End------------');
  }

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      itemCount: moves.length,
      itemBuilder: (BuildContext context, int index) {
         return JKHomeMovieItem(moves[index]);
      }
    );
  }
}
